package com.ruoyi.supply.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.supply.enums.AdminAuditLogTableEnum;
import com.ruoyi.supply.enums.SupplyInfoStatusEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.supply.mapper.TAdminAuditLogMapper;
import com.ruoyi.supply.domain.TAdminAuditLog;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * 管理员审核日志Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-06-06
 */
@Service
public class TAdminAuditLogService extends ServiceImpl<TAdminAuditLogMapper, TAdminAuditLog>
{
    @Autowired
    private TAdminAuditLogMapper tAdminAuditLogMapper;

    @Transactional(rollbackFor = Exception.class)
    public void insertLog(AdminAuditLogTableEnum tableEnum, SupplyInfoStatusEnum statusEnum,Long fkTableId){
        TAdminAuditLog tAdminAuditLog = new TAdminAuditLog();
        tAdminAuditLog.setCreateTime(new Date());
        tAdminAuditLog.setFkTableName(tableEnum.getTableName());
        tAdminAuditLog.setFkTableId(fkTableId);
        tAdminAuditLog.setType(statusEnum.getCode());
        tAdminAuditLog.setFkUserId(SecurityUtils.getUserId());
        save(tAdminAuditLog);
    }

}
